import i18next from "i18next";
import { initReactI18next } from "react-i18next";
import en from "./en.json";
import pt from "./pt.json";
import store from "@/store";

const { app:{ language = 'en' } = {} } = store.getState()

const resources = {
  en: { translation: en },
  pt: { translation: pt },
};

i18next.use(initReactI18next).init({
  resources,
  fallbackLng: language, //默认当前环境的语言
  detection: {
    caches: ["localStorage", "sessionStorage", "cookie"],
  },
});

export default i18next;